package com.example.stock.entity.dao;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.stock.entity.eo.AmountVolEo;
import com.example.stock.entity.mapper.AmountVolMapper;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class AmountVolDao extends ServiceImpl<AmountVolMapper, AmountVolEo> {


    public List<String> listTopTen(LocalDateTime localDateTime) {
        return getBaseMapper().selectPage(new Page<>(1, 10),
                Wrappers.<AmountVolEo>lambdaQuery()
                        .orderByDesc(AmountVolEo::getAmount)
                        .eq(AmountVolEo::getTradeTime, localDateTime)
        )
                .convert(t -> t.getTsCode())
                .getRecords();
    }

    public List<String> listTopTen_(LocalDateTime preTime, LocalDateTime startTime) {
        return getBaseMapper().listTopTen(preTime,startTime);
    }
}
